package com.itheima;

public class Test04 {

    //有以下数组：
    //int[] arr = {21,22,23,24,25,26};
    //请定义方法getSum()，计算数组中：偶数索引位置上，并且元素是偶数的累加和。

    public static void main(String[] args) {
        int[] arr = {21,22,23,24,25,26,12};

        int sum = getSum(arr);

        System.out.println(sum);
    }
    public static int getSum(int[] arr) {
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            if (i % 2 == 0 && arr[i] % 2 == 0) {
                sum +=arr[i];
            }
        }
        return sum;
    }
}
